﻿using EnterpriseWebsiteApi.ActionResults;
using EnterpriseWebsiteApi.Dto;
using EnterpriseWebsiteUtil.Helper;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace EnterpriseWebsiteApi.Controllers.Admin
{
    [Route("api/admin/[controller]/[action]")]
    [ApiController]
    public class TestController : ControllerBase
    {
        public readonly LangSplitHelper  _langSplitHelper;
        public TestController(LangSplitHelper langSplitHelper)
        {
            _langSplitHelper = langSplitHelper;
        }

        /// <summary>
        /// 多语言结构返回例子
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ActionResult LangData()
        {
            var test = new TestDTO
            {
                name = "你好",
                nameEn = "hello",
                title = "测试",
                children = new List<ChildDTO> {
                    new ChildDTO {
                        childName = "孩子",
                        childNameEn = "child",
                        url = "http://example.com"
                    }
                }
            };
            var result = _langSplitHelper.SplitByLang(test);
            return new Success(result);
        }
    }
}
